import { Component, OnInit, Input } from '@angular/core';

import { AppGlobalService } from './../../shared/service/app-global.service';

@Component({
  selector: 'app-quotation-remark',
  templateUrl: './quotation-remark.component.html',
  styleUrls: ['./quotation-remark.component.scss'],
})
export class QuotationRemarkComponent implements OnInit {

  @Input()tagData: any;
  constructor(
    private appGlobalService: AppGlobalService,
  ) { }

  ngOnInit() {
    // this.demoData();
  }

  ngAfterViewInit(): void {

    // tslint:disable-next-line:prefer-for-of
    for (let i = 0; i < this.tagData.data.items.length; i++) {
      const content: string = this.tagData.data.items[i].content;
      document.getElementById('desc' + i.toString() ).innerHTML = content.replace('\\n', '<br>');
    }

  }

  detailInfo(data) {
    if (data.type === 'page') {
      const pageParams = {
        pageId: data.target,
        params: data.params,
        sessionId: localStorage.getItem('sessionId')
      };
      this.appGlobalService.goToForward(pageParams);
    } else if (data.type === 'url') {
      this.appGlobalService.openUrl(this.tagData.data.detailContent.title, data.target);
     }
  }
  demoData() {
    this.tagData = {
      type: 'tag',
      style: 'xxxx',
      name: 'xxxx',
          // 标准报价内容
          data: {
            title: "服务内容",
            subTitle: "开通服务尊享4大超值礼包",
            detailContent: {
              title: "了解详情",
              link: {
                type: "page",
                target: "pageId",
                params: {}
            }
            },
            items: [{
                iconName: "../../../assets/icon/vip_icon_net@3x.png",
                title: "全网推广",
                content: "各大知<br>平台展示;",
                content2: "转让图文广告"
              },
              {
                iconName: "../../../assets/icon/vip_icon_app@3x.png",
                title: "全网推广",
                content: "各大知<br>平台展示;",
                content2: "转让图文广告"
              },
              {
                iconName: "../../../assets/icon/vip_icon_ai@3x.png",
                title: "全网推广",
                content: "各大知<br>平台展示;",
                content2: ""
              },
              {
                iconName: "../../../assets/icon/vip_icon_vip@3x.png",
                title: "全网推广",
                content: "各大知\t\n平台展示;",
                content2: "转让图文广告"
              }
            ]
        }
    };
  }
}
